﻿@model SDSystem.Models.Programme        
@using Ext.Net;
@using Ext.Net.MVC;
@{
    ViewBag.Title = "Edit Programme";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Header
{
    <script>
        function deactiveProgramme() {
            var count1 = @ViewBag.CountSvProgramme;
            var id = @ViewBag.ProgrammeId;
            var conf1 = confirm("Do you want to mark this Programme in-active?");
            if(conf1==true) {
                if (count1 > 0) {
                    var conf2 = confirm("This Programme is already in use, do you want to make this in-active?");
                    if (conf2 == true) {
                        App.direct.DeactiveProgrammeHaveCheck(id);
                        alert("Deactive Successfull");
                    } else {
                        alert("No Programme is deactive");
                    }
                } else {
                    App.direct.DeactiveProgrammeHaveCheck(id);
                    alert("Deactive Successfull");
                }
            }else {
                alert("No Programme is deactive");
            }

        }
    </script>
}

@(Html.X().TabPanel()
      .Region(Region.Center)
      .MarginSpec("0 0 0 0")
      .Items(
          Html.X().FormPanel()
              .ID("FormPanel1")
              .Title("Edit Programme")
              .BodyPadding(10)
              .Layout(LayoutType.Form)
                  .Items(
              Html.X().FieldContainer().Layout(LayoutType.HBox).Items(
                      Html.X().HiddenFor(m => m.ProgrammeId),
                      Html.X().TextFieldFor(m => m.ProgrammeName).EmptyText("New Programme Name Test").Flex(2).Margins("0 10 10 5").FieldLabel("Programme Name <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side),
                      Html.X().TextField().ID("ContactLookup").Text(ViewBag.ContactName).Flex(1).Margins("0 10 10 5").FieldLabel("Contact").LabelWidth(200).AllowBlank(false).MsgTarget(MessageTarget.Side),
                          Html.X().HiddenFor(m => m.ContactId).ID("hIdLookup"),
                      Html.X().LinkButton().Text("Lookup").Listeners(
                          li => li.Click.Handler = "showWindow('Lookup','/Contact/List/?text=ContactLookup&id=hIdLookup',true,0.85,0.85);")
                      ),
              Html.X().FieldContainer().Layout(LayoutType.HBox).Items(
                      Html.X().TextAreaFor(m => m.Description).Rows(3).EmptyText("New Test Programme Description Test").Flex(1).Margins("0 10 10 5").FieldLabel("Description").LabelWidth(200)
                     ),
              Html.X().CheckboxFor(m => m.IsActive).Flex(1).Margins("0 10 10 5").FieldLabel("Is Active?").LabelWidth(200)
              )
              .TopBar(Html.X().Toolbar().Items(items =>
                                                         {
                                                             items.Add(new ToolbarTextItem {Text = "<h3 style=\"color:green\">Programme Details</h3>"});

                                                             items.Add(new ToolbarFill());
                                                         })
                                               .Items(
                                                            Html.X().Button().Text("<b>Deactive</b>").Icon(Icon.StopRed).Listeners(ls => ls.Click.Handler = "deactiveProgramme();window.parent.location.reload();parentAutoLoadControl.close();"),
                                                            Html.X().Button().ID("btnSave").Text("<b>Save</b>").Margins("0 20 0 0").Icon(Icon.Disk).DirectEvents(de =>
                                                            {
                                                                de.Click.Url = Url.Action("EditCommit");
                                                                de.Click.EventMask.ShowMask = true;
                                                                de.Click.FormID = "FormPanel1";
                                                            })
                                                            .Listeners(ls => ls.Click.Handler = "window.parent.location.reload();parentAutoLoadControl.close();"),
                                                            Html.X().Button().Text("<b>Back</b>").Icon(Icon.PageBack).Margins("0 20 0 0")
                                                            .Listeners(ls => ls.Click.Handler = "parentAutoLoadControl.close();")
                                                            
                                               )

                )
         )
         
 )

                
